<?php

//查看测评结果的视图$groupname,$sort,$usertable
function project_grade($groupname,$sort,$usertable){
	$sortlength=0;
	$sortlengthz=0;
	$sortlengthh=0;
	$sortlengthc=0;
	if(isset($sort[1])){
		$sortlengthz=count($sort[1])+1;
	}
	if(isset($sort[2])){
		$sortlengthh=count($sort[2])+1;
	}
	if(isset($sort[3])){
		$sortlengthc=count($sort[3])+1;
	}
	$sortlength=2+$sortlengthz+$sortlengthh+$sortlengthc;
	?>
	<div class="model">
	<table>
		<tr>
			<td colspan=<?php echo "'".$sortlength."'"; ?>>
				<?php echo $groupname;?>
			</td>
		</tr>
		<tr>
			<td colspan="2">\</td>
			<?php
				if($sortlengthz){
					echo "<td colspan='".$sortlengthz."'>自评</td>";
				}
				if($sortlengthh){
					echo "<td colspan='".$sortlengthh."'>互评</td>";
				}
				if($sortlengthc){
					echo "<td colspan='".$sortlengthc."'>测评</td>";
				}
			?>
		<tr>
			<td>用户名</td>
			<td>姓名</td>
			<?php
			foreach ($sort as $key => $value) {
				foreach ($value as $okey => $ovalue) {
					echo "<td>";
					echo $ovalue;
					echo "</td>";
				}
				echo "<td>总分</td>";	
			}
			?>
		</tr>
		<?php
		foreach ($usertable as $key => $value) {
			echo "<tr>";
			echo "<td>".$value['userid']."</td>";
			echo "<td>".$value['username']."</td>";
			foreach ($sort as $vkey => $vvalue) {
				foreach ($vvalue as $tkey => $tvalue) {
					echo "<td>".$value['usergrade'][$vkey][$tkey]."</td>";
				}
				echo "<td>".$value['usergrade'][$vkey]['总分']."</td>";
			}
			echo "</tr>";
		}
		?>
	</table>
	</div>
	<?php
}
?>